﻿@model IEnumerable<DotNetUniLodz.Models.Article>
<section id="News" class="News100">
    @foreach (var item in Model)
    {
        <article class="Article100">
            <header>
                @Html.ActionLink(item.Article_title, "Details", "Articles", new { id = item.Article_id }, null)
            </header>
            <div>
                @Html.Partial("_DisplayNewsInfo", item)
                <p>
                    @{
        item.Article_text = System.Text.RegularExpressions.Regex.Replace(item.Article_text, "<[^>]*>", string.Empty);
                    }
                    @if (item.Article_text.Length > 200)
                    {
                        //@item.Article_text.Substring(0, 200) Write("...");
                        @Html.Raw(item.Article_text.Substring(0, 200) + "...")
                    }
                    else
                    {
                        // @item.Article_text
                        @Html.Raw(item.Article_text)
                    }
                </p>
            </div>
            <footer>
                @{
                    if (item.Event_id != null)
                    {                    
                    @*<a href="@item.Event.Event_link" class="ArticleRegister">@item.Event.Event_name</a>*@
                    @Html.ActionLink(item.Event.Event_name, "Details", "Events", new { id = item.Event.Event_id }, new { @class = "ArticleRegister" })
                    }            
                }
                @Html.ActionLink("Więcej informacji", "Details", "Articles", new { id = item.Article_id }, new { @class = "ArticleMore" })

                @if (User.IsInRole("Admin"))
                {
                    <div class="AdminLinks">
                        @Html.ActionLink("Edytuj", "Edit", "Articles", new { id = item.Article_id }, null) |
                        @Html.ActionLink("Usuń", "Delete", "Articles", new { id = item.Article_id }, null)
                    </div>
                }
            </footer>
        </article>
    }
</section>
